<?php


namespace EchoPHP\Foundation\Support;


class ServerBag extends ParameterBag {

    /**
     * 获取http头信息
     * @return array
     */
    public function getHeaders() {
        $headers = [];
        $contentHeaders = ['CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true];
        foreach ($this->parameters as $key => $value) {
            if (0 === strpos($key, 'HTTP_')) {
                $headers[substr($key, 5)] = $value;
            } elseif (isset($contentHeaders[$key])) {
                $headers[$key] = $value;
            }

            //todo - HTTP头认证信息暂不处理
        }

        return $headers;
    }
}